<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../../fonts/iconfont/iconfont.css">
		<script src="../../js/mui.min.js"></script>
		<script src="../../libs/artTemplate.js"></script>
		<script src="../../js/app/common.js"></script>
		<script>
			(function(doc, win) {
				        var html = doc.getElementsByTagName("html")[0],
				        // orientationchange->手机屏幕转屏事件
				        // resize->页面大小改变事件(一边pc端有用)
				            reEvt = "orientationchange" in win ? "orientationchange" : "resize",
				            reFontSize = function() {
				                var clientW = doc.documentElement.clientWidth || doc.body.clientWidth;
				                if(!clientW) {
				                    return;
				                }
				                html.style.fontSize = 100 * (clientW / 420) + "px";
				        }
				        win.addEventListener(reEvt, reFontSize);
				
				        // DOMContentLoaded->dom加载完就执行,onload要dom/css/js都加载完才执行
				        doc.addEventListener("DOMContentLoaded", reFontSize);
				    })(document, window);
			</script>
		<style type="text/css">
			* {
				-webkit-user-select: none;
				-ms-touch-select: none;
				padding: 0rem;
				margin: 0rem;
				touch-action: pan-y;
			}

			.mui-content,
			body {
				background: #FFFFFF;
			}

			.bgImg {
				height: 1.6rem;
				width: 100%;
				background-image: url(../../images/head_Bx.jpg);
				background-size: 100% auto;
				background-repeat: no-repeat;
			}

			.customerInfo_box {
				padding: 0px;
				position: relative;
				box-shadow: 0px -5px 10px 0px rgba(217, 217, 217, 0.6);
			}

			.customerInfo_box .img {
				text-align: center;
				display: inline-block;
				width: 30%;
			      height: 0.8rem;
				  position: relative;
			}

			.customerInfo_box img {
					position: absolute;
				top: -0.3rem;
				height: 0.9rem;
				width: 0.9rem;
				box-shadow:0 0 3px 0px rgba(182, 181, 181, 1);
				border-radius: 50%;
				left: 0.15rem;
 			}

			.ringt_info {
				width: 70%;
				display: inline-block;
				text-align: left;
				float: right;
				padding: 0.1rem 0rem;
			}
			  .titlebox{
				      background: #e5f8fd;
								  padding: 0.05rem 0.1rem;
				  border-bottom: 1px solid #eee;
			}
			.titlebox>h5{
				border-left: 4px solid #47BAFE;
				padding-left: 0.05rem;
				font-size: 0.14rem;
				color: #626262;
			}
			.bxzh_box {
				/* box-shadow: 0 0 5px 0px #f2eeee; */
		margin: 0rem 0.1rem;
		border:1px solid #EEEEEE;
			}
			.bxzh_box ul{
				margin: 0px 0.1rem;
			}
			.bxzh_box ul:after{
				background: none !important;
			}
			.bxzh_box ul:before{
				background: none !important;
			}
			.bxzh_box ul li{
				padding-left: 0.05rem;
				padding-right: 0.05rem;
				font-size: 0.15rem;
				border-bottom: 1px solid #f1f6ff;
				padding: 0.1rem 0rem;
			}
				.bxzh_box ul li:last-child{
					border: none;
				}
			
				.bxzh_box ul li p{
				  font-size: 0.14rem;
				  margin: 0rem;
				}
				.mui-table-view li p{
					  position: relative !important;
				}
				.insertbxbtn {
					text-align: center;
					
				}
				.insertbxbtn >button{
					width: 70%;
					border-color: #47BAFE;
					background: #47BAFE;
				}
				.mui-table-view p span{
					width: 33%;
					margin-right: 0.1rem;
					display: inline-block;
					font-size: 0.13rem;
				}
				.mui-table-view  li{
					position: relative;
				}
			  	.mui-table-view  .CPtype{
					background:#79c4e9;
					width: 0.60rem;
					color: #FFFFFF;
					height: 0.30rem;
					line-height: 0.30rem;
					border-radius: 5px;
						text-align: center;
						right: 0rem;
						position: absolute;
						font-size: 0.13rem;
						top: 0.3rem;
				}
				 .sharebox {
					 line-height: 0.5rem;
					 padding-left: 0.15rem;
					 height: 0.5rem;
				 }
			       .sharebox div{
					   margin-right: 0.1rem;
					   float: left;
					   display: inline-block;
					   font-size: 0.4rem;
					   color:#62b900;
				   }
						
				    .sharebox a>img{
						transform: translateY(0.05rem);
					}
			  .sales_card{
				  /* /* box-shadow: 0 0 5px 0px #b4cbe5; */
					    /* box-shadow: 0 0 10px 0px #f2eeee; */
						border: 1px solid #EEEEEE;
				  padding:0.13rem 0.1rem;
				  display: flex;
				  border-radius: 5px;
				  margin: 0px 0.1rem;
				  height: 1.2rem;
			  }
			   .sales_card .img{
				   display: inline-block;
				   height: 0.4rem;
				   margin-right: 0.05rem;
				   vertical-align:middle
			   }
			     .sales_card  .col{
					 width: 70%;
				 }
				  .sales_card  .col:last-child{
					  display: flex;
					  width: 30%;
					  align-items: center;
					  justify-content: flex-end;
					  text-align: right;
				  }
				  .sales_card .col:last-child img{
					    height: 0.8rem;
					  width: 0.8rem;
					  vertical-align: middle;
				  }
				  #backbtn{
					  transform:translate(15px,10px);
					  background:rgba(0, 0, 0, 0.3);
					  width: 0.35rem;
					  border-radius: 50%;
					  height: 0.35rem;
					  line-height: 0.35rem;
					  text-align: center;
					  color: #FFFFFF;
				  }
				  #head_img{
					  border-radius: 50%;
				  }
				  .HaiBaoBox{
					  position: fixed;
					  z-index: 999;
					  width: 3rem;
					  height: 3rem ;
				  }
				
		</style>
	</head>
	<body style="display: none;">
	<!-- 	<div class="HaiBaoBox">
			 <img id="Haibao" style="width: 100%;" src="" alt="">
		</div> -->
		<div class="mui-content" style="position: relative;" >
			<div id="schbBox">

			<div class="bgImg">
				<div id="backbtn"><i class="mui-icon mui-icon-back"></i></div>
			</div>
			<div  class="customerInfo_box">
				<div class="img">
					<img id="imgtx" src="../../images/mrtxF.jpg" alt=""></div>
				<div class="ringt_info">
					<span id="cust_nm">李艳呀</span> 
					<i class="iconfont" id="customer_sex" style="font-size: 0.12rem; color: #47BAFE;">&#xe650;</i> <!-- <i>&#xe650;</i> -->
					<p>快去分享TA的保险组合吧</p>
					<!-- <p>所在城市：上海</p> -->
				</div>
				<div class="bxzh_box">
					<div class="titlebox">
					<h5>已购保险</h5>
					</div>
					<ul class="mui-table-view" id="baoxian_m" >
					</ul>
				
					<!-- <p></p>
					<div class="insertbxbtn">
					<button type="button" class="mui-btn mui-btn-primary "><i class='mui-icon mui-icon-plusempty' style="font-size: 0.22rem;"></i> 添加其它保险</button>
					</div> -->
				</div>
			</div>
			<!-- <br> -->
			<p></p>
			 <div class="sales_card">
				  <div class="col">
					  <div class="img">
					  <img id="head_img" src="../../images/default_pick_photo.png" style="height: 0.4rem; width: 0.4rem;" alt="">
					  </div>
					  <div style="display: inline-block;height: 0.4rem; vertical-align:middle;font-size:0.16rem ;line-height: 0.22rem;">
						 <div style="font-size: 0.15rem;" id="YwyNm">还没有填名字</div>
						  <p style="font-size: 0.13rem;margin: 0rem;" id="company">未填写所属公司</p>
					  </div>
					  <p></p>
					  <p style="margin: 0rem; font-size: 0.13rem;" >
						  <i class="mui-icon mui-icon-phone" style="font-size:0.18rem;" ></i>&nbsp; <span id="phone">未填写手机号</span></p>
					  <p style="font-size: 0.13rem;margin: 0rem;"><i class="mui-icon mui-icon-weixin"  style="font-size:0.18rem; color: #d1d1d1"></i>&nbsp; <span id="wechatNo">未设置微信号</span></p>
				  </div>
				  <div class="col"  >
					  <img id="wechat_img" src="" alt="">
					  <p id="no_wechatImg" style="text-align: left;display: none;font-size: 0.13rem;">未设置微信二维码</p>
				  </div>
			 </div>
			 </div>
			 	<p></p>
			 <div class="sharebox">
			 	<p style="display: inline-block;height: 0.5rem;line-height: 0.5rem;float: left;">分享到：</p>
			 	<div onclick="download(1)" class="iconfont">&#xe6d9;</div>
			 	<div onclick="download(2)" class="iconfont">&#xe6a4;</div>
			 	<div onclick="download(3)" style="float: none;" >
					<img src="../../fonts/iconfont/WXSC.png" style="height: 0.41rem;width: 0.4rem; transform: translateY(6px);" alt=""></a>
			 	</div>
		</div>
		
			<script type="text/html" id="baoxian_tp">
				{{each DATASET as value}} {{if value!=''}}
				<li>
					<div>{{value.product_nm}}</div>
				<p><span>保费：{{value.product_fee}}元</span><span>保额：{{value.product_premium/10000}}万</span>&nbsp;&nbsp;<span>保险期限：{{value.product_period}}年</span><span>被保人：{{value.product_beneficial}}</span>
				{{if value.product_cover!=""}}
				 <p style="background: #f6f6f6; padding: 0.05rem;margin: 0rem;">保障内容：{{value.product_cover}}</p>
				 {{/if}}
					<div class="CPtype">{{value.product_type}}</div>
				</p>
				</li>
			{{/if}}
			{{/each}}
		</script>
		<script>
		var shares=null;
		var sweixin=null;
		var ww=null,bitmap=null;
		
		// var buttons=[
		//   {title:'微信好友',extra:{scene:'WXSceneSession'}},
		//   {title:'微信朋友圈',extra:{scene:'WXSceneTimeline'}},
		//   {title:'微信收藏',extra:{scene:'WXSceneFavorite'}}
		// ];
			let custId;
			let name;
			mui.plusReady(function(){
				updateSerivces();
				 storage.init();
				storageUser = kidstorageuser.getInstance();
				let self=plus.webview.currentWebview();
				if(self.img=="../../images/mrtxF.jpg"){
					document.getElementById("customer_sex").innerHTML="&#xe62d;";
					document.getElementById("customer_sex").style.color="red";
				}else{
					document.getElementById("customer_sex").innerHTML="&#xe650;";
					document.getElementById("customer_sex").style.color="#47BAFE";
				}
				document.getElementById("cust_nm").innerText=self.name;
				document.getElementById("imgtx").setAttribute("src",self.img);
				getCard();
				// alert(JSON.stringify(storageUser));
					 custId=self.cust_id;
					 name=self.name;
				getInfo(self.sales_id,self.cust_id);
				
			})
			document.addEventListener("getcardinfo",function(e){
					var storageData = {
					PlayerId: e.detail.PlayerId,
					Mobile: e.detail.Mobile,
					NickName: e.detail.NickName,
					imgurl: e.detail.imgurl,
					SelfdomSign: e.detail.SelfdomSign,
					tel_no: e.detail.tel_no,
					wechat_no: e.detail.wechat_no,
					wechat_img: e.detail.wechat_img,
					profile_img:e.detail.profile_img,
					sex: e.detail.sex,
					duty: e.detail.duty,
					company: e.detail.company,
					city: e.detail.city
					//cityid:data.CityId
				}
				storageUser.login(storageData);
					document.getElementById("YwyNm").innerText = e.detail.NickName;
				document.getElementById("phone").innerText=e.detail.tel_no;
				if(e.detail.wechat_no!=""){
					document.getElementById("wechatNo").innerText=e.detail.wechat_no;
				}
				if(e.detail.company!=""){
					document.getElementById("company").innerText=e.detail.company;
				}
				if(e.detail.imgurl!=""){
						 var filename = e.detail.imgurl.substring(e.detail.imgurl.lastIndexOf("/") + 1, e.detail.imgurl.length);  
					var relativePath = "_doc/headimg/" + filename;  
					//判断本地是否存在此图片
					plus.io.resolveLocalFileSystemURL(relativePath , function(entry) {
						//存在就直接设置图片src
						console.log("存在");
							var sd_path = plus.io.convertLocalFileSystemURL(relativePath);  
							document.getElementById("head_img").setAttribute("src",sd_path);
							//转成手机绝对路径
					},function(e){
						console.log("不存在");
							document.getElementById("head_img").setAttribute("src",e.detail.imgurl);
					})
				}
					
					if(e.detail.wechat_img!=""){
						document.getElementById("no_wechatImg").style.display="none";
						document.getElementById("wechat_img").style.display="block";
						document.getElementById("wechat_img").setAttribute("src",e.detail.wechat_img)
					}else{
						document.getElementById("wechat_img").style.display="none";
						document.getElementById("no_wechatImg").style.display="block";
					}
			})
			function getCard(){
					document.getElementById("YwyNm").innerText = storageUser.NickName;
				document.getElementById("phone").innerText=storageUser.TelNo;
				document.getElementById("wechatNo").innerText=storageUser.wechatNo;
				if(storageUser.company!=""){
					document.getElementById("company").innerText=storageUser.company;
				}
				if(storageUser.ImgUrl!=""){
					document.getElementById("head_img").setAttribute("src",storageUser.ImgUrl);
				}
					if(storageUser.wechatImg!=""){
								document.getElementById("no_wechatImg").style.display="none";
						document.getElementById("wechat_img").style.display="block";
						document.getElementById("wechat_img").setAttribute("src",storageUser.wechatImg)
					}else{
						document.getElementById("wechat_img").style.display="none";
						document.getElementById("no_wechatImg").style.display="block";
					}
			}

           document.getElementById("backbtn").addEventListener("tap",function(){
			   mui.back();
		   })
		   	document.addEventListener("shareinfo",function(e){
		   	       let type=e.detail.type;
		   		let wxshare={"title":"微信好友","extra":{scene:"WXSceneSession"}};
		   	    if(type==2){
		   			wxshare={"title":"微信朋友圈","extra":{scene:"WXSceneTimeline"}};
		   		}else if(type==3){
		   			wxshare={"title":"微信收藏","extra":{scene:"WXSceneFavorite"}};
		   		}
		   		var msg = {
		   					pictures: [e.detail.url]
		   					};
		   	sweixin?share(sweixin,msg, wxshare):plus.nativeUI.alert('当前环境不支持微信分享操作!'); 
		   })
		   document.addEventListener("getbx",function(e){
			
				getInfo(e.detail.sales_id,e.detail.cust_id);
				 name=e.info.name;
				 img=e.info.img;
				 custId=e.info.cust_id;
				 salesId=e.info.sales_id;
		   })
		   	   function getInfo(salesId,custId){
			
				   mui.post("http://118.25.184.62:8000/cmdb/queryProductByCustID/",{
					   	 sales_id:salesId,
					   cust_id:custId
				   },function(data){
					  render("#baoxian_m","baoxian_tp",data)
					  document.body.style.display="block";
				   },'json');
		   }
		 	function updateSerivces(){
		 	plus.share.getServices(function(s){
		 		shares={};
		 		for(var i in s){
		 			var t=s[i];
		 			shares[t.id]=t;
		 		}
		     sweixin=shares['weixin'];
		 	}, function(e){
		 		outSet('获取分享服务列表失败：'+e.message);
		 	});
		 }
		  
		
		   	function download(type){
				if(storageUser.wechatNo=="" || storageUser.wechatImg==""){
					mui.confirm('<div style="text-align:left">您的个人信息不全，建议现在设置提高获客效率！</div>', '灵豹提醒', ['不了', '马上去'], function(e) {
						if (e.index == 1) {
							mui.openWindow({
								 url:'../mine/myInfo.html',  
								id:'myInfo.html',  
									show:{
									  autoShow:true,//页面loaded事件发生后自动显示，默认为true
									  aniShow:"pop-in",//页面显示动画，默认为”slide-in-right“；
									  duration:250//页面动画持续时间，Android平台默认100毫秒，iOS平台默认200毫秒；
									},	
								styles: {
									titleNView: {
										autoBackButton: true,
										backgroundcolor: "#47BAFE",
										titleText: "个人信息",
										titlecolor: "white",
									},
							
								},
								waiting: {
									autoShow: false
								}  
							});
						}
					}, 'div')
					
					return;
				}else{
					plus.webview.create("share.html","share.html",{},{
							custId:custId,
							type:type,
							name:name
					});
				}
			

		 }
		 
		 function share(srv, msg, button){
		 	// outSet('分享操作：');
		   if(!srv){
		     // outLine('无效的分享服务！');
		     return;
		   }
		   button&&(msg.extra=button.extra);
		 	// 发送分享
		 	if(srv.authenticated){
		 		// outLine('---已授权---');
		 		doShare(srv, msg);
		 	}else{
		 		// outLine('---未授权---');
		 		srv.authorize(function(){
		 			doShare(srv, msg);
		 		}, function(e){
		 			// outLine('认证授权失败：'+JSON.stringify(e));
		 		});
		 	}  
		 }
		 // 发送分享
		 function doShare(srv, msg){
		 	// outLine(JSON.stringify(msg));
		 	srv.send(msg, function(){
				document.getElementById("backbtn").style.opacity="1";
		 		// outLine('分享到"'+srv.description+'"成功！');
		 	}, function(e){
		 		// outLine('分享到"'+srv.description+'"失败: '+JSON.stringify(e));
		 	});
		 }
		 // 解除授权
		 function cancelAuth(){
		 	// outSet('解除授权：');
		   if(sweixin){
		     if(sweixin.authenticated){
		     	// outLine('取消"'+sweixin.description+'"');
		     }
		     sweixin.forbid();
		   }else{
		     // outLine('当前环境不支持微信分享操作!');
		   }
		 }
		</script>
	</body>
</html>
